#ifndef ___fat32_operacionAT_obtener_cadena_sectores_desde_clusteres

#define ___fat32_operacionAT_obtener_cadena_sectores_desde_clusteres 1

#include "f32_mto.c"

unsigned char fat32op_obtener_cadena_sectores_desde_clusteres(FAT32_PARAMS_OPERACION);

unsigned char fat32op_obtener_cadena_sectores_desde_clusteres (FAT32_PARAMS_OPERACION) {
  unsigned long * clusteres = datosEntrada;
  unsigned long cantidadClusteres = 0;
  while (clusteres[cantidadClusteres]) cantidadClusteres ++;
  unsigned long * sectores = malloc(sizeof(unsigned long) * (bootsector.sectoresPorCluster * cantidadClusteres + 1));
  unsigned long numCluster, sector;
  unsigned char numSector;
  unsigned long posSector;
  struct fat32_posicion_sector pos;
  pos.sector = 0;
  for (numCluster = 0, posSector = 0; numCluster < cantidadClusteres; numCluster ++) {
    pos.cluster = clusteres[numCluster];
    sector = fat32_obtener_sector_lineal(pos, 0);
    for (numSector = 0; numSector < bootsector.sectoresPorCluster; numSector ++, posSector ++)
      sectores[posSector] = sector + numSector;
  }
  sectores[posSector] = 0;
  *datosSalida = sectores;
  return 1;
}

#endif